package es.deusto.ingenieria.tesoroaventurero;

import java.util.ArrayList;
import java.util.List;

import es.deusto.ingenieria.is.formulation.Problem;
import es.deusto.ingenieria.is.search.Node;
import es.deusto.ingenieria.is.search.SearchMethod;
import es.deusto.ingenieria.tesoroaventurero.Mover.Sentido;

public class TesoroAventureroProblem extends Problem {


	protected void createOperators() {
		super.addOperator(new Mover(Sentido.ABAJO));
		super.addOperator(new Mover(Sentido.ARRIBA));
		super.addOperator(new Mover(Sentido.DERECHA));
		super.addOperator(new Mover(Sentido.IZQUIERDA));

	}

	
	public void solve(SearchMethod searchMethod){
		Node finalNode = searchMethod.search(this, this.getInitialStates().get(0));
		
		if (finalNode != null){
			List<String> operators = new ArrayList<String>();
			searchMethod.solutionPath(finalNode, operators);
			searchMethod.createSolutionLog(operators);
			System.out.println("Solution found!");
			System.out.println(operators);
//			System.out.println("Coordenadas: " + ((((Escenario)finalNode.getState().getInformation()).getPersonaje().x)+1) + "-" 
//			+ ((((Escenario)finalNode.getState().getInformation()).getPersonaje().y)+1));
		}
		else{
			System.out.println("Unable to find the solution!");
		}
	}
	
}
